#include<iostream>
#include<set>

using namespace std;

void printSet(set<int> & s){
    for(set<int>::iterator it = s.begin(); it!=s.end();it++){
        cout<<*it<<endl;
    }
}

void test01(){
    set<int> s1;
    s1.insert(5);
    s1.insert(1);
    s1.insert(9);
    s1.insert(3);
    s1.insert(7);
    printSet(s1);
}

void test02(){
    set<int> s1;
    set<int>::iterator pos  = s1.find(3);
    if(pos!=s1.end()){
        cout<<"找到"<<endl;
    }

    int num = s1.count(1); //统计数量

    set<int>::iterator it = s1.lower_bound(3); //key>=3的迭代器
    if(it!=s1.end()){
        cout<<"找到了"endl;
    }
    set<int>::iterator it2 = s1.upper_bound(3);
    //第一个key>keyElem元素的迭代器
    if(it2!=s1.end()){
        cout<<"找到了"<<endl;
    }

    pair<set<int>::iterator, set<int>::iterator> ret = s1.equal_range(3);
    //返回上下限
    if(ret.first!=s1.end()){
        cout<<"找到"<<endl;
    }
}

//指定set的排序规则，从大到小
//需要构建仿函数
class myCompare{
    public:
    bool operator()(int v1, int v2){
        return v1>v2;
    }
};

void test03(){
    set<int, myCompare> s1;
    s1.insert(5);    
    s1.insert(1);    
    s1.insert(2);    
    for(set<int,myCompare>::iterator it=s1.begin(); it!=s1.end(); it++){
        cout<<*it<<" ";
    }
}

int main(){
    Person p("zhangsan", 20, Person::BOY);
    cout<<p.get_age()<<endl;
    cout<<p.add_age(10).get_age()<<endl;
    return 0;
}